<html xmlns:th="http://www.thymeleaf.org">
<head>
    <link type="text/css" href="/topjui/css/myui.css" rel="stylesheet"/>
</head>
<body>
<form id="customerform" method="post" style="padding-top:1px">
    <input type="hidden" id="id" name="id" value="0">
    <table class="editTable">
        <tr>
            <td class="label">上级类型ID</td>
            <td>
                <input type="text" id="typeid" name="typeid"  class="selectp easyui-validatebox" readonly data-options="required:true" style="width:212px;">
            </td>
        </tr>
        <tr>
            <td class="label">上级类型名称</td>
            <td>
                <input type="text" name="typename" autocomplete="off" class="inputp" data-options="required:true" style="width: 156px;">
                <input type="button" id="findsub" name="findsub" class="l-btn topjui-btn-normal l-btn-small" value="查询" style="width: 56px">
            </td>
        </tr>
        <tr>
            <td class="label">类型名称</td>
            <td>
                <input type="text" name="name"  class="selectp easyui-validatebox" autocomplete="off" data-options="required:true" style="width:212px;">
            </td>
        </tr>
    </table>
</form>
<script th:inline="javascript">
    $(function () {
        $("#findsub").on('click',function (event){
            var typename = $("input[name='typename']").val();
            $.ajax({
                url: '/jdgoods/findtype',
                data:{'typename':typename},
                dataType: 'json',
                success: function (r) {
                    if (r.code == '200') {
                        $("input[name='typeid']").val(r.result)
                    }
                    if(r.code == '500') {
                        $.messager.alert('提示', r.message);
                    }
                }
            });
        });
    })

</script>
</body>
</html>